package com.my.exceptions;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

/**
 * @author marshal
 * @version 2021-05-21
 */
public class ExceptionsTest {

    public static void main(String[] args) {
//        checkedExceptionTest("/sss");
        runtimeExceptions(10, 0);
    }

    public static void checkedExceptionTest(String filename) {
        FileReader f = null;
        try {
            f = new FileReader(filename);
        } catch (IOException e) {
            System.out.println("异常信息： " + e.getMessage());
        } finally {
            if (f != null) {
                try {
                    f.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    public static void runtimeExceptions(int a, int b) {
        try {
            int c = a / b;
        } catch (ArithmeticException e) {
            System.out.println("异常信息：" + e.getMessage());
        }
    }

}
